package com.jimmy.medical.entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * 服务项目
 * 
 * @author jimmy
 * @since 0.1
 */
@Entity
@Table(name = "service_item")
public class ServiceItem extends AbstractEntity {
	/** 服务名称*/
	@Column(name = "name", length = 100)
	private String name;
	/** 简介*/
	@Column(name = "description", length = 2000)
	private String description;
	/** 服务菜单*/
	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "service_menu_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private SysCode serviceMenu;
	/** 图标*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "icon_id")
	@NotFound(action = NotFoundAction.IGNORE)
	private UploadFile icon;
	/** 服务类型*/
	@ManyToMany(cascade={CascadeType.REMOVE}, fetch=FetchType.LAZY)
	@JoinTable(name="service_item_type",joinColumns={@JoinColumn(name="item_id",referencedColumnName="id")},inverseJoinColumns={@JoinColumn(name="type_id",referencedColumnName="id")})
	private Set<SysCode> serviceTypes = new TreeSet<SysCode>();
	/** 服务流程,1:体检;2:陪诊;3:挂号;4:评估*/
	@Column(name = "service_flow", length = 100)
	private String serviceFlow;
	
	/** 图片说明*/
	@ManyToMany(cascade={CascadeType.REMOVE}, fetch=FetchType.LAZY)
	@JoinTable(name="service_item_image",joinColumns={@JoinColumn(name="item_id",referencedColumnName="id")},inverseJoinColumns={@JoinColumn(name="image_id",referencedColumnName="id")})
	private List<UploadFile> imageList = new ArrayList<UploadFile>();

	/** 服务项目*/
	@OneToMany(cascade = {CascadeType.REMOVE}, fetch=FetchType.LAZY, mappedBy="item" )
	@OrderBy("id asc")
	private Set<ServicePrice> prices = new TreeSet<ServicePrice>();
	
	/**
	 * 是否显示到app
	 */
	@Column(name = "is_show_app",length = 1)
	private String isShowApp;

	/**
	 * 所属城市(逗号分隔，前后无逗号，如果要like查询，自己在前面和后面加上逗号“‘，’||‘”)
	 */
	@Column(name = "city_list", length = 128)
	private String cityList;

	/**
	 * 作弊人次
	 */
	@Column(name="cheating_num")
	private Integer cheatingNum;

	
	/**
	 * 服务价格类型（1-单个、2-多个）
	 */
	@Column(name="service_price_type", length=1)
	private String servicePriceType;
	
	/**
	 * 服务价格（单个时有效）
	 */
	@Column(name="service_price")
	private Integer servicePrice;


	/**
	 * 服务内容
	 */
	@Column(name="service_content")
	private String serviceContent;
	/** 是否启用*/
	@Column(name = "is_enabled", length = 1)
	private String isEnabled;
	

	/** 服务方式*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "service_mode_id")
	@NotFound(action = NotFoundAction.IGNORE)
	private SysCode serviceMode;
	
	@Column(name = "create_time", length = 20)
	private String createTime;
	@Column(name = "create_user", length = 50)
	private String createUser;
	@Column(name = "update_time")
	private String updateTime;
	@Column(name = "update_user", length = 20)
	private String updateUser;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public SysCode getServiceMenu() {
		return serviceMenu;
	}

	public void setServiceMenu(SysCode serviceMenu) {
		this.serviceMenu = serviceMenu;
	}
	
	public UploadFile getIcon() {
		return icon;
	}

	public void setIcon(UploadFile icon) {
		this.icon = icon;
	}

	public Set<SysCode> getServiceTypes() {
		return serviceTypes;
	}

	public void setServiceTypes(Set<SysCode> serviceTypes) {
		this.serviceTypes = serviceTypes;
	}

	public String getServiceFlow() {
		return serviceFlow;
	}

	public void setServiceFlow(String serviceFlow) {
		this.serviceFlow = serviceFlow;
	}

	public List<UploadFile> getImageList() {
		return imageList;
	}

	public void setImageList(List<UploadFile> imageList) {
		this.imageList = imageList;
	}

	public Set<ServicePrice> getPrices() {
		return prices;
	}

	public void setPrices(Set<ServicePrice> prices) {
		this.prices = prices;
	}

	public String getIsShowApp() {
		return isShowApp;
	}

	public void setIsShowApp(String isShowApp) {
		this.isShowApp = isShowApp;
	}

	public SysCode getServiceMode() {
		return serviceMode;
	}

	public String getCityList() {
		return cityList;
	}

	public void setCityList(String cityList) {
		this.cityList = cityList;
	}

	public Integer getCheatingNum() {
		return cheatingNum;
	}

	public void setCheatingNum(Integer cheatingNum) {
		this.cheatingNum = cheatingNum;
	}

	public String getServicePriceType() {
		return servicePriceType;
	}

	public void setServicePriceType(String servicePriceType) {
		this.servicePriceType = servicePriceType;
	}

	public Integer getServicePrice() {
		return servicePrice;
	}

	public void setServicePrice(Integer servicePrice) {
		this.servicePrice = servicePrice;
	}

	public String getServiceContent() {
		return serviceContent;
	}

	public void setServiceContent(String serviceContent) {
		this.serviceContent = serviceContent;
	}
	public String getIsEnabled() {
		return isEnabled;
	}

	public void setIsEnabled(String isEnabled) {
		this.isEnabled = isEnabled;
	}

	public void setServiceMode(SysCode serviceMode) {
		this.serviceMode = serviceMode;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getCreateUser() {
		return createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	public String getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}

	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
}
